<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
       <ui:define name="breadcrumbs">
        <h:form id="menuHeader">
            <a href="index.xhtml">Website Admin</a><div class="breadcrumb_divider"></div>
            <h:commandLink action="#{classesController.prepareList()}" value="Courses" class="current"/>
        </h:form>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form" id="form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorClass="errorStyle" infoClass="infoStyle" layout="table" >
                    </h:messages>
                </h:panelGroup>

                <h:outputText escape="false" value="#{bundle.ListClassesEmpty}" rendered="#{classesController.items.rowCount == 0}" class="infoStyle"> 
                </h:outputText>
                <article class="module width_full">
			<header><h3>List of Classes</h3></header>
                        <div class="module_content">
                <h:panelGroup rendered="#{classesController.items.rowCount > 0}">
                    <p:dataTable value="#{classesController.items}" var="item" paginator="true" rows="10" 
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15" style="width: 100%" styleClass="tablesorter">
                        <p:column sortBy="#{item.id}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListClassesTitle_id}"/>
                            </f:facet>
                            <h:outputText value="#{item.id}"/>
                            
                        </p:column>
                        <p:column sortBy="#{item.className}" filterBy="#{item.className}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListClassesTitle_className}"/>
                            </f:facet>
                            <h:commandLink value="#{item.className}" action="#{studentsController.listStudentInClass(item)}"/>
                        </p:column>
                        <p:column sortBy="#{item.courseId.courseName}" filterBy="#{item.courseId.courseName}"   
                                  filterOptions="#{classesController.allCourse}"  
                filterMatchMode="exact">
                            <f:facet name="header">
                                <h:outputText value="Course"/>
                            </f:facet>
                            <h:outputText value="#{item.courseId.courseName}"/>
                        </p:column>
                        <p:column style="width: 150px; text-align: center;">
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandButton action="#{classesController.prepareEdit()}" title="Edit"
                                            image="#{resource['images:icn_edit_article.png']}">
                               <f:setPropertyActionListener value="#{item}" target="#{classesController.selected}"/>
                           </h:commandButton>
                           <h:outputText value="&nbsp;"/>
                           <h:commandButton action="#{classesController.destroy}" title="Delete"
                                            image="#{resource['images:icn_trash.png']}">
                               <f:setPropertyActionListener value="#{item}" target="#{classesController.selected}"/>
                           </h:commandButton>
                           <h:outputText value="&nbsp;"/>
                           <h:commandButton action="#{classesController.prepareView()}" title="View"
                                            image="#{resource['images:icn_folder.png']}">
                               <f:setPropertyActionListener value="#{item}" target="#{classesController.selected}"/>
                           </h:commandButton>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
                <br />
                <h:commandButton action="#{classesController.prepareCreate}" value="#{bundle.ListClassesCreateLink}"/>
                <br />
                <br />
                
                </div></article>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
